<template>
  <div>
    <!-- 第一排 -->
    <el-row :gutter="30">
      <el-col :span="20">
        <h1>用户管理</h1>
      </el-col>
    </el-row>
    <el-row :gutter="30">
      <el-col :span="20" style="margin:20px 0px 0px 100px;align:center;">
        <!-- 表格展示数据 -->
        <el-table :data="userData" border style="width:1100px;">
          <el-table-column fixed prop="id" label="序号" width="100" align="center">
          </el-table-column>
          <el-table-column prop="userName" label="用户姓名" width="120" align="center">
          </el-table-column>
          <el-table-column prop="email" label="用户邮箱" width="120" align="center">
          </el-table-column>
          <el-table-column prop="phone" label="用户手机" width="120" align="center">
          </el-table-column>
          <el-table-column prop="address" label="用户地址" width="120" align="center">
          </el-table-column>
          <el-table-column prop="avatar" label="用户头像" width="180" align="center">
            <template slot-scope="scope">
              <el-image
                  style="width: 100px; height: 100px"
                  :src="scope.row.foodImg"
                  :preview-src-list="[scope.row.foodImg]"
                  fit="contain">
              </el-image>
            </template>
          </el-table-column>

          <el-table-column fixed="right" label="操作" width="300px" >
            <template slot-scope="scope">
              <!-- 这块下面是修改按钮 -->
              <el-button type="primary" @click="updateFoodById(scope.row)">修改
              </el-button>
              <!-- 这块下面是上架按钮 -->
              <el-button type="info" v-if="scope.row.foodStatus == 0" @click="shangFoodStatus(scope.row.id)">未售
              </el-button>
              <!-- 这块下面是下架按钮 -->
              <el-button type="success" v-if="scope.row.foodStatus == 1" @click="xiaFoodStatus(scope.row.id)">在售
              </el-button>
              <!-- 这块下面是删除按钮 -->
              <el-button type="danger" @click="deleteFoodById(scope.row.id)">删除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: "User",
  data(){
    return{
      userData:[],
    };
  },
  mounted() {
    this.getAllUser()
  },
  methods:{
    // 全查方法
    getAllUser() {
      //请求方式为get
      this.$axios.get("http://localhost:9527/backstagesupporter/food/getAllFood").then(res => {//获取返回结果
        this.userData = res.data.data;
        console.log(res)
      }).catch(e =>{
        console.log(e)
      })
    },
  }
}
</script>

<style scoped>

</style>
